<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%proxy_pay_back}}".
 *
 * @property int $id
 * @property int $proxy_pay_id
 * @property int $created_at
 * @property int $state 交易状态
 * @property string $result
 * @property string $reason 原因
 * @property int $original_created_at 原请求日期
 * @property int $back_time 退票日期
 * @property string $fuiou_order_no 富有原交易流水
 * @property string $back_order_no 退票流水
 * @property string $accnt_no 银行卡号
 * @property string $accnt_nm 银行卡号账户名
 * @property string $bank_no 总行代码
 * @property int $amount 总额
 * @property string $other_data
 *
 * @property ProxyPay $proxyPay
 */
class ProxyPayBack extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%proxy_pay_back}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['proxy_pay_id', 'created_at'], 'required'],
            [['proxy_pay_id', 'created_at', 'state', 'original_created_at', 'back_time', 'amount'], 'integer'],
            [['result', 'reason', 'other_data'], 'string'],
            [['fuiou_order_no', 'back_order_no', 'accnt_no', 'accnt_nm', 'bank_no'], 'string', 'max' => 50],
            [['proxy_pay_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProxyPay::className(), 'targetAttribute' => ['proxy_pay_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'proxy_pay_id' => Yii::t('app', 'Proxy Pay ID'),
            'created_at' => Yii::t('app', 'Created At'),
            'state' => Yii::t('app', '交易状态'),
            'result' => Yii::t('app', 'Result'),
            'reason' => Yii::t('app', '原因'),
            'original_created_at' => Yii::t('app', '原请求日期'),
            'back_time' => Yii::t('app', '退票日期'),
            'fuiou_order_no' => Yii::t('app', '富有原交易流水'),
            'back_order_no' => Yii::t('app', '退票流水'),
            'accnt_no' => Yii::t('app', '银行卡号'),
            'accnt_nm' => Yii::t('app', '银行卡号账户名'),
            'bank_no' => Yii::t('app', '总行代码'),
            'amount' => Yii::t('app', '总额'),
            'other_data' => Yii::t('app', 'Other Data'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getProxyPay()
    {
        return $this->hasOne(ProxyPay::className(), ['id' => 'proxy_pay_id']);
    }
}
